package com.aggeek.springbootlearning.netstufy;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;

/**
 * author:liuao
 * description:
 * Date: create on 16:31 2017/12/12
 * modify by:
 */
public class NetTest {
    public static void main(String[] args){
        try {
            String envo = System.getProperty("env");
            InetAddress byName = InetAddress.getByName("127.0.0.1");

            NetworkInterface byInetAddress = NetworkInterface.getByInetAddress(byName);
            //InetAddress localHost = InetAddress.getByName("www.aoaoshop.com");
            InetAddress localHost = InetAddress.getLocalHost();
            String hostAddress = localHost.getHostAddress();
            System.out.println(hostAddress);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (SocketException e) {
            e.printStackTrace();
        }
    }
}
